<?php
include_once('common/header.php');	
if($AppUI->id <= 0 || !isset($_SERVER['HTTP_REFERER'])) {	
	Vfriend_Function::redirect(HOST_VFRIEND);
}
$strRefer		= isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '';
$intUserId		= Vfriend_Function::base64D($objRequest->getParam('puserid',0));
$strToken		= $objRequest->getParam('ptoken','');
$strFullname	= $objRequest->getParam('pfullname','');
$intVon			= $objRequest->getParam('pvon',0);
$strTok			= $intUserId . '_' . $AppUI->id;
$strSession		= isset($_SESSION['giveVon' . $strTok]) ? $_SESSION['giveVon' . $strTok] : '';
$intError		= 0;
if(strlen($intVon) > 6) {
	$intError = 2;
}
if($intError == 0 && $intUserId && $strToken != '' && $strSession != '' && Vfriend_Function::isValidLink($strRefer) && $strToken == $strSession && $intVon) {
	unset($_SESSION['giveVon' . $strTok]);
	if($AppUI->id != $intUserId) {
		$objURequest = new URequest();
		$intError	 = $objURequest->addGiveVon($AppUI->id,$intUserId,$intVon);
		if($intError == 0) {
			$strMessage	= $arrMessage[1];
			$strMessage	= str_replace('[strFullname]', $strFullname, $strMessage);
			Vfriend_Function::setMsg($strMessage);
		} else $intError += 3;
	} else {
		$intError = 3;
	}
} else {
	$intError = 1;
}
if($intError > 0) {
	$strError	= $arrError[$intError];
	$strError	= str_replace('[strFullname]',$strFullname,$strError);
	Vfriend_Function::setError($strError);
}
Vfriend_Function::redirect(isset($strRefer) ? $strRefer : HOST_VFRIEND);

?>